GoldenMorning 2.8\" ILI9341 SPI TFT (Non-Touch) + D1 Mini (ESP8266)
Wiring & Demo (Adafruit Libraries) — README.txt
================================================

Overview
--------
This project shows how to wire a GoldenMorning 2.8-inch TFT (ILI9341, SPI, with SD slot but *not used here*) to a D1 Mini (ESP8266) and display a full-screen RGB565 image from `imag1.h`. 
On boot, a green rounded progress bar with the label "Love of My Life" animates for ~1200 ms, then the image is shown.

Requirements
------------
1) Arduino IDE with ESP8266 board package (D1 Mini / LOLIN(WEMOS) D1 R2 & mini)
2) Libraries (Library Manager → Install):
   - Adafruit GFX Library
   - Adafruit ILI9341
3) A header file `imag1.h` containing an **RGB565** bitmap array generated by **image2cpp**:
   - Symbol name: `epd_bitmap_Untitled_1`
   - Format: `const uint16_t ... PROGMEM` (stored in flash, not RAM)
   - Dimensions: 320x240 (landscape; matches rotation=1)

Wiring (D1 Mini ↔ TFT)
----------------------
TFT Pin     | Function       | D1 Mini Pin
----------- | -------------- | -----------
VCC         | +3.3V          | 3V3
GND         | Ground         | G
CS          | Chip Select    | D8 (GPIO15)
DC          | Data/Command   | D3 (GPIO0)
RESET (RST) | Reset          | D4 (GPIO2)
SDI (MOSI)  | SPI MOSI       | D7 (GPIO13)
SCK         | SPI Clock      | D5 (GPIO14)
SDO (MISO)  | SPI MISO       | D6 (GPIO12) — optional (not required if SD unused)
LED         | Backlight      | 3V3 (or drive via a transistor/GPIO if brightness control needed)

Notes:
- Touch pins (T_IRQ, T_DO, T_DIN, T_CS, T_CLK) are not used (non-touch mode).
- Both D1 Mini and ILI9341 are 3.3V logic, so no level shifter is needed.
- If you see flicker/tearing, comment out the fast SPI line (`SPI.setFrequency(40000000);`). Default speed is fine.

imag1.h (example stub)
----------------------
Your actual file exported by image2cpp will have thousands of values; keep only one array.
Make sure it is **RGB565** and **PROGMEM**.

Example:
------------------------------------------------------------
#include <pgmspace.h>

// 320x240 landscape RGB565 image exported by image2cpp
const uint16_t epd_bitmap_Untitled_1[] PROGMEM = {
  // 0xFFFF, 0xABCD, ... (many values)
};
------------------------------------------------------------

Main Sketch
-----------
Copy this into a new Arduino sketch (.ino) in the same folder as imag1.h.
It shows a green rounded (pill-shaped) progress bar (~1200 ms), then draws your full-screen image.

------------------------------------------------------------
#include <Arduino.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>

#define TFT_CS   D8
#define TFT_DC   D3
#define TFT_RST  D4
// SPI: SCK=D5, MOSI=D7, MISO=D6 (optional)

Adafruit_ILI9341 tft(TFT_CS, TFT_DC, TFT_RST);

// ---- your image header (RGB565, PROGMEM) ----
#include "imag1.h"   // const uint16_t epd_bitmap_Untitled_1[] PROGMEM;

// ------- CONFIG -------
const int16_t imgW = 320;
const int16_t imgH = 240;

void drawProgressBarRounded(const char* label)
{
  tft.fillScreen(ILI9341_BLACK);
  tft.setTextSize(2);
  tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

  // Center label above bar
  int16_t x1, y1; uint16_t w, h;
  tft.getTextBounds(label, 0, 0, &x1, &y1, &w, &h);
  int16_t lx = (tft.width() - (int16_t)w) / 2;
  int16_t ly = (tft.height() / 2) - 30;
  tft.setCursor(lx, ly);
  tft.print(label);

  // Progress bar geometry
  const int barW = 260;
  const int barH = 18;
  const int bx   = (tft.width() - barW) / 2;
  const int by   = (tft.height() / 2) + 4;
  const int r    = barH / 2;   // rounded ends radius

  // Border + cavity
  tft.drawRoundRect(bx - 2, by - 2, barW + 4, barH + 4, r + 2, ILI9341_DARKGREY);
  tft.fillRoundRect(bx, by, barW, barH, r, ILI9341_BLACK);

  // Animate ~1200ms total
  const int TOTAL_MS = 1200;
  const int STEPS    = 60;
  const int STEP_MS  = TOTAL_MS / STEPS;

  for (int p = 1; p <= STEPS; p++) {
    int L = (barW * p) / STEPS;
    int w = L;
    if (w < 2 * r) w = 2 * r;    // keep pill ends rounded when small
    if (w > barW) w = barW;

    tft.fillRoundRect(bx, by, w, barH, r, ILI9341_GREEN);
    delay(STEP_MS);
  }
}

void drawImageFullScreen()
{
  int16_t x = (tft.width()  - imgW) / 2;   // 0 in landscape
  int16_t y = (tft.height() - imgH) / 2;   // 0 in landscape
  tft.drawRGBBitmap(x, y, epd_bitmap_Untitled_1, imgW, imgH);
}

void setup() {
  delay(150);
  tft.begin();
  SPI.setFrequency(40000000);   // comment out if unstable
  tft.setRotation(1);           // landscape 320x240

  // --- Rounded green progress bar (no percentage) ---
  drawProgressBarRounded("Love of My Life");

  // --- Show the image ---
  drawImageFullScreen();
}

void loop() {
  // nothing
}
------------------------------------------------------------

Troubleshooting
---------------
- Colors look wrong: Re-export from image2cpp, toggle the RGB565 byte order (Little vs Big Endian).
- Incomplete/garbled image: Ensure width/height are exactly 320x240 and array type is uint16_t RGB565 in PROGMEM.
- Flicker or random lines: Comment out SPI.setFrequency(40000000) to use default speed.
- Compiler issues: Check that ESP8266 board package is installed and the correct board is selected.

Credits
-------
Display: GoldenMorning 2.8\" TFT (ILI9341 SPI)
MCU: D1 Mini (ESP8266)
Libraries: Adafruit GFX, Adafruit ILI9341

Enjoy!
